package com.lu.statistics.common.utils;

public class PasswordUtils {
    /**
     * 密码正则匹配
     * <p>
     * 正则表达式用于匹配至少包含两种类型的密码：小写字母、大写字母、数字、特殊字符
     */
    private static final String PWD_STRENGTH_REGEX =
            "^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[!@#$%^&*]).+$";
    /**
     * 密码正则匹配
     * 密码不应使用世界常见口令,比如 passw@rd、admin@123;
     */
    private static final String PWD_REGEX = "^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[$@$!%*?&]).{8,}$";

    private PasswordUtils() {
    }


    public static boolean checkPassword(String password) {
        // 1.数字、大写字母、小写字母、特殊符号的组合，长度为8-26位
        return password.matches(PWD_STRENGTH_REGEX) && password.matches(PWD_REGEX);
    }

    public static void main(String[] args) {
        boolean b = checkPassword("fastpcPasswArd123!");
        System.out.println(b);
    }

}
